package com.ruoyi.web.controller.system;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.SysEvaluateaverage;
import com.ruoyi.system.service.ISysEvaluateaverageService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 评价评分Controller
 * 
 * @author ruoyi
 * @date 2020-12-13
 */
@Controller
@RequestMapping("/system/evaluateaverage")
public class SysEvaluateaverageController extends BaseController
{
    private String prefix = "system/evaluateaverage";

    @Autowired
    private ISysEvaluateaverageService sysEvaluateaverageService;

    @RequiresPermissions("system:evaluateaverage:view")
    @GetMapping()
    public String evaluateaverage()
    {
        return prefix + "/evaluateaverage";
    }

    /**
     * 查询评价评分列表
     */
    @RequiresPermissions("system:evaluateaverage:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(SysEvaluateaverage sysEvaluateaverage)
    {
        startPage();
        List<SysEvaluateaverage> list = sysEvaluateaverageService.selectSysEvaluateaverageList(sysEvaluateaverage);
        return getDataTable(list);
    }

    /**
     * 导出评价评分列表
     */
    @RequiresPermissions("system:evaluateaverage:export")
    @Log(title = "评价评分", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(SysEvaluateaverage sysEvaluateaverage)
    {
        List<SysEvaluateaverage> list = sysEvaluateaverageService.selectSysEvaluateaverageList(sysEvaluateaverage);
        ExcelUtil<SysEvaluateaverage> util = new ExcelUtil<SysEvaluateaverage>(SysEvaluateaverage.class);
        return util.exportExcel(list, "evaluateaverage");
    }

    /**
     * 新增评价评分
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存评价评分
     */
    @RequiresPermissions("system:evaluateaverage:add")
    @Log(title = "评价评分", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(SysEvaluateaverage sysEvaluateaverage)
    {
        return toAjax(sysEvaluateaverageService.insertSysEvaluateaverage(sysEvaluateaverage));
    }

    /**
     * 修改评价评分
     */
    @GetMapping("/edit/{evaluateAverageId}")
    public String edit(@PathVariable("evaluateAverageId") Long evaluateAverageId, ModelMap mmap)
    {
        SysEvaluateaverage sysEvaluateaverage = sysEvaluateaverageService.selectSysEvaluateaverageById(evaluateAverageId);
        mmap.put("sysEvaluateaverage", sysEvaluateaverage);
        return prefix + "/edit";
    }

    /**
     * 修改保存评价评分
     */
    @RequiresPermissions("system:evaluateaverage:edit")
    @Log(title = "评价评分", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(SysEvaluateaverage sysEvaluateaverage)
    {
        return toAjax(sysEvaluateaverageService.updateSysEvaluateaverage(sysEvaluateaverage));
    }

    /**
     * 删除评价评分
     */
    @RequiresPermissions("system:evaluateaverage:remove")
    @Log(title = "评价评分", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(sysEvaluateaverageService.deleteSysEvaluateaverageByIds(ids));
    }
}
